<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="../Brushes/Common.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="ScrollableTabControl" TargetType="{x:Type TabControl}">
        <Setter Property="Padding" Value="4,4,4,4"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="BorderBrush" Value="{StaticResource GroupBoxOuterBorder}"/>
        <Setter Property="Background" Value="{StaticResource SelectedTabItemOuterBackground}"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabControl}">
                    <Grid ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition x:Name="ColumnDefinition0"/>
                            <ColumnDefinition x:Name="ColumnDefinition1" Width="0"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" x:Name="RowDefinition0"/>
                            <RowDefinition Height="*" x:Name="RowDefinition1"/>
                        </Grid.RowDefinitions>
                        <ScrollViewer x:Name="ScrollViewer" Grid.Column="0" Grid.Row="0" VerticalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Auto">
                            <ScrollViewer.Template>
                                <ControlTemplate TargetType="{x:Type ScrollViewer}">
                                    <Grid x:Name="Grid" Background="{TemplateBinding Background}">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="*"/>
                                            <ColumnDefinition Width="Auto"/>
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="*"/>
                                        </Grid.RowDefinitions>
                                        <ScrollContentPresenter Margin="18,0,18,0" x:Name="PART_ScrollContentPresenter" CanContentScroll="{TemplateBinding CanContentScroll}" CanHorizontallyScroll="False" CanVerticallyScroll="False" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Grid.Column="0" Grid.Row="0" Panel.ZIndex="1"/>
                                        <ScrollBar x:Name="PART_VerticalScrollBar" AutomationProperties.AutomationId="VerticalScrollBar" Cursor="Arrow" Grid.Column="0" Grid.Row="0" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"  ViewportSize="{TemplateBinding ViewportHeight}" Width="Auto" Height="Auto" Style="{DynamicResource ScrollBarWithoutTrack}" />
                                        <ScrollBar x:Name="PART_HorizontalScrollBar" AutomationProperties.AutomationId="HorizontalScrollBar" Cursor="Arrow" Grid.Column="0" Grid.Row="0" Maximum="{TemplateBinding ScrollableWidth}" Minimum="0" Orientation="Horizontal" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportWidth}" Width="Auto" Height="Auto" Style="{DynamicResource ScrollBarWithoutTrack}" />
                                    </Grid>
                                    <ControlTemplate.Triggers>
                                        <Trigger Property="VerticalScrollBarVisibility" Value="Auto">
                                            <Setter Property="Margin" Value="0,18,0,18" TargetName="PART_ScrollContentPresenter"></Setter>
                                        </Trigger>
                                        <Trigger Property="VerticalScrollBarVisibility" Value="Disabled">
                                            <Setter Property="Margin" Value="18,0,18,0" TargetName="PART_ScrollContentPresenter"></Setter>
                                        </Trigger>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </ScrollViewer.Template>
                            <TabPanel Margin="2,0,2,0" x:Name="HeaderPanel" IsItemsHost="true" Panel.ZIndex="1" KeyboardNavigation.TabIndex="1"/>
                        </ScrollViewer>
                        <Border x:Name="ContentPanel" Grid.Column="0" Grid.Row="1" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" KeyboardNavigation.DirectionalNavigation="Contained" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local">
                            <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="{TemplateBinding Padding}" x:Name="PART_SelectedContentHost" ContentSource="SelectedContent"/>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="TabStripPlacement" Value="Bottom">
                            <Setter Property="Grid.Row" TargetName="ScrollViewer" Value="1"/>
                            <Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
                            <Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
                            <Setter Property="Height" TargetName="RowDefinition1" Value="Auto"/>
                            <Setter Property="Margin" TargetName="HeaderPanel" Value="2,0,2,0"/>
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Left">
                            <Setter Property="Grid.Row" TargetName="ScrollViewer" Value="0"/>
                            <Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
                            <Setter Property="Grid.Column" TargetName="ScrollViewer" Value="0"/>
                            <Setter Property="Grid.Column" TargetName="ContentPanel" Value="1"/>
                            <Setter Property="Width" TargetName="ColumnDefinition0" Value="Auto"/>
                            <Setter Property="Width" TargetName="ColumnDefinition1" Value="*"/>
                            <Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
                            <Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
                            <Setter Property="Margin" TargetName="HeaderPanel" Value="0,2,0,2"/>
                            <Setter Property="VerticalScrollBarVisibility" TargetName="ScrollViewer" Value="Auto"></Setter>
                            <Setter Property="HorizontalScrollBarVisibility" TargetName="ScrollViewer" Value="Disabled"></Setter>
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Right">
                            <Setter Property="Grid.Row" TargetName="ScrollViewer" Value="0"/>
                            <Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
                            <Setter Property="Grid.Column" TargetName="ScrollViewer" Value="1"/>
                            <Setter Property="Grid.Column" TargetName="ContentPanel" Value="0"/>
                            <Setter Property="Width" TargetName="ColumnDefinition0" Value="*"/>
                            <Setter Property="Width" TargetName="ColumnDefinition1" Value="Auto"/>
                            <Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
                            <Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
                            <Setter Property="Margin" TargetName="HeaderPanel" Value="0,2,0,2"/>
                            <Setter Property="VerticalScrollBarVisibility" TargetName="ScrollViewer" Value="Auto"></Setter>
                            <Setter Property="HorizontalScrollBarVisibility" TargetName="ScrollViewer" Value="Disabled"></Setter>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Background" Value="{StaticResource DisabledTabItemOuterBackground}"/>
                            <Setter Property="BorderBrush" Value="{StaticResource DisabledTabItemOuterBorder}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="TabItemFocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle SnapsToDevicePixels="true" Stroke="Black" StrokeDashArray="1 2" StrokeThickness="1" Margin="3,3,3,1"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="CompactIconTabItem" TargetType="{x:Type TabItem}">
        <Setter Property="FocusVisualStyle" Value="{StaticResource TabItemFocusVisual}"/>
        <Setter Property="Foreground" Value="{StaticResource TabItemForeground}"/>
        <Setter Property="FontFamily" Value="Verdana"/>
        <Setter Property="FontSize" Value="11"/>
        <Setter Property="FontWeight" Value="Normal"/>
        <Setter Property="Padding" Value="1,0,1,0"/>
        <Setter Property="Margin" Value="-2,0,0,0"/>
        <Setter Property="BorderBrush" Value="{StaticResource TabItemOuterBorder}"/>
        <Setter Property="Background" Value="{StaticResource TabItemOuterBackground}"/>
        <Setter Property="BorderThickness" Value="1,1,0,0"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabItem}">
                    <Grid SnapsToDevicePixels="true" x:Name="GridCnt" Margin="0,0,0,-1">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <Border SnapsToDevicePixels="true" Grid.Column="0" x:Name="OuterBorder" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                            <Border SnapsToDevicePixels="true" x:Name="InnerBorder" Background="{StaticResource TabItemInnerBackground}"  BorderBrush="{StaticResource TabItemInnerBorder}" BorderThickness="{TemplateBinding BorderThickness}">
                                <ContentPresenter SnapsToDevicePixels="True" Margin="0,0,0,0" HorizontalAlignment="Center" x:Name="Content" VerticalAlignment="Center" ContentSource="Header" RecognizesAccessKey="True"/>
                            </Border>
                        </Border>
                        <Canvas Grid.Column="1" x:Name="CanvasShape" Width="5" Height="42" Canvas.Left="0" Canvas.Top="0" Margin="-1,0,0,0">
                            <Path SnapsToDevicePixels="True" x:Name="PBackground" Width="5" Height="42" Canvas.Left="5.72205e-006" Canvas.Top="1.90735e-006" Stretch="Fill" Fill="{TemplateBinding Background}" Data="F1 M 5.72205e-006,1.90735e-006C 5.72205e-006,6.66667 5.72205e-006,13.3333 5.72205e-006,20C 6.66667,20 13.3333,20 20,20C 9.03441,20 12.25,1.90735e-006 5.72205e-006,1.90735e-006 Z "/>
                            <Path SnapsToDevicePixels="True" x:Name="PInnerBorder" Width="6" Height="41" Canvas.Left="-1.499993" Canvas.Top="1" Stretch="Fill" StrokeLineJoin="Round" Stroke="{StaticResource TabItemInnerBorder}" Data="F1 M 20,19.5C 7.99653,19.5 11.632,1.5 6.65585e-006,1.5"/>
                            <Path SnapsToDevicePixels="True" x:Name="POuterBorder" Width="6" Height="41" Canvas.Left="-0.499994" Canvas.Top="-1.90735e-006" Stretch="Fill" StrokeLineJoin="Round" Stroke="{TemplateBinding BorderBrush}" Data="F1 M 20,18.6C 9.03441,18.6 12.25,0.5 5.72205e-006,0.499998"/>
                        </Canvas>

                    </Grid>
                    <ControlTemplate.Triggers>

                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter Property="Background" Value="{StaticResource HoverTabItemOuterBackground}"/>
                            <Setter Property="BorderBrush" Value="{StaticResource HoverTabItemOuterBorder}"/>
                            <Setter Property="Background" TargetName="InnerBorder" Value="{StaticResource HoverTabItemInnerBackground}"/>
                            <Setter Property="BorderBrush" TargetName="InnerBorder" Value="{StaticResource HoverTabItemInnerBorder}"/>
                            <Setter Property="Stroke" TargetName="PInnerBorder" Value="{StaticResource HoverTabItemInnerBorder}"/>
                            <Setter Property="Foreground" Value="{StaticResource HoverTabItemForeground}"/>
                        </Trigger>
                        <Trigger Property="IsSelected" Value="true">
                            <Setter Property="Background" Value="{StaticResource SelectedTabItemOuterBackground}"/>
                            <Setter Property="BorderBrush" Value="{StaticResource SelectedTabItemOuterBorder}"/>
                            <Setter Property="Background" TargetName="InnerBorder" Value="{StaticResource SelectedTabItemInnerBackground}"/>
                            <Setter Property="BorderBrush" TargetName="InnerBorder" Value="{StaticResource SelectedTabItemInnerBorder}"/>
                            <Setter Property="Stroke" TargetName="PInnerBorder" Value="{StaticResource SelectedTabItemInnerBorder}"/>
                            <Setter Property="Foreground" Value="{StaticResource SelectedTabItemForeground}"/>
                            <Setter Property="Panel.ZIndex" Value="1"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Background" Value="{StaticResource DisabledTabItemOuterBackground}"/>
                            <Setter Property="BorderBrush" Value="{StaticResource DisabledTabItemOuterBorder}"/>
                            <Setter Property="Background" TargetName="InnerBorder" Value="{StaticResource DisabledTabItemInnerBackground}"/>
                            <Setter Property="BorderBrush" TargetName="InnerBorder" Value="{StaticResource DisabledTabItemInnerBorder}"/>
                            <Setter Property="Stroke" TargetName="PInnerBorder" Value="{StaticResource DisabledTabItemInnerBorder}"/>
                            <Setter Property="Foreground" Value="{StaticResource DisabledTabItemForeground}"/>
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Bottom">
                            <Setter Property="LayoutTransform">
                                <Setter.Value>
                                    <ScaleTransform ScaleX="1" ScaleY="-1"/>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="LayoutTransform" TargetName="Content">
                                <Setter.Value>
                                    <ScaleTransform ScaleX="1" ScaleY="-1"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Left">
                            <Setter Property="LayoutTransform">
                                <Setter.Value>
                                    <RotateTransform Angle="-90"/>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="LayoutTransform" TargetName="Content">
                                <Setter.Value>
                                    <RotateTransform Angle="90" />
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Margin" Value="0,-2,0,-2"/>
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Right">
                            <Setter Property="LayoutTransform">
                                <Setter.Value>
                                    <RotateTransform Angle="90"/>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="LayoutTransform" TargetName="Content">
                                <Setter.Value>
                                    <RotateTransform Angle="-90" />
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Margin" Value="0,-2,0,-2"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>